<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script src="../static/vue.js"></script>
<script src="../static/axios.js"></script>
<script src="../static/util.js"></script>
<body>
    <button onclick="location.href='add.html'">添加</button>
    <div id="app">
        <table border="1" cellspacing="0">
            <tr>
                <td>编号</td>
                <td>姓名</td>
                <td>性别</td>
                <td>密码</td>
                <td>年龄</td>
                <td>电话</td>
                <td>操作</td>
            </tr>
            <tr v-for="user in list">
                <td>{{user.id}}</td>
                <td>{{user.name}}</td>
                <td>{{user.gender}}</td>
                <td>{{user.password}}</td>
                <td>{{user.age}}</td>
                <td>{{user.tel}}</td>
                <td>
                    <a @click="findById(user.id)">修改</a>
                    <a @click="del(user.id)">删除</a>
                </td>
            </tr>
        </table>
    </div>
</body>
<script>
    new Vue({
        el:"#app",
        data:{
            list:[]
        },
        created(){
            this.findAll()
        },
        methods:{
            del(id){
                axios.get("http://localhost:8080/sys/user/del?id="+id).then(
                    res =>{
                        location.href="user.html"
                    }
                )
            },
            findById(id){
                location.href="update.html?id="+id;
            },
            findAll(){
                axios.get("http://localhost:8080/sys/user/findAll").then(
                    res=>{
                        this.list = res.data;
                    }
                )
            }
        }
    })
</script>
</html>